/**
*	流程模块： 单位模块flowunit的扩展js
*	开发者：雨中磐石
*	地址：www.rockoa.com
*	日期：2023-07-29
*/

//录入页使用
js.flowunit_input = function(){
	
	
	this.initbodys = function(){
		
		
	}
	

}


js.flowunit_list = function(){
	
	var me = this;

	this.initbodys = function(){
		this.setcolumns('isflow',{
			renderer:function(v){
				if(v=='无流程'){
					return '';
				}
			}
		});
		if(this.params.otype=='company'){
			this.settable({
				sort:'sort',dir:'asc'
			});
			this.setcolumns('cid',{
				hidden:true
			});
			if(this.isadd==1){
				var sid = 'btnstr_'+this.rand+'';
				this.addlefthtml('<button type="button" id="'+sid+'" class="webbtn bg-warn"><i class="icon-plus"></i> 新增系统模块</button>');
				$('#'+sid+'').click(function(){
					me.listobj.clickxuanmok();
				});
			}
		}else{
			this.optobj.addhide();
		}
	}
	
	this.clickxuanmok = function(){
		var cans = {
			url:'api/company/flowmode',
			title:'从系统模块里新增',
			checked:true,
			cnum:this.cnum,
			onselect:function(sel,sna,sid){
				if(sid)me.listobj.savemode(sid);;
			},
			onrenderdata:function(d){
				d.subname = d.num+' '+d.type;
				if(d.stotal>0){
					d.subname+=' 已加过';
					d.name = '<s>'+d.name+'</s>';
				}
				d.iconsimg = d.imgurl;
				d.value = d.id;
				return d;
			}
		}
		importjs('selectdata','create',cans);
	}
	
	this.savemode = function(sid){
		js.ajax.post({
			url:'api/company/flowmodesave',
			cnum:this.cnum,
			data:{sid:sid},
			loading:'新增中...',
			loadsuccess:'新增成功',
			onsuccess:function(){
				me.table.reload();
			}
		});
		
	}
	
}